class Project < ActiveRecord::Base

  hobo_model
  
  has_many :tasks
  
  belongs_to :user
  belongs_to :owner, :class_name => "User", :foreign_key => "owner_id"
  
  set_creator_attr :user

  # --- Hobo Permissions --- #

  def creatable_by?(creator)
    creator == user and creator.administrator?
  end

  def updatable_by?(updater, new)
    (updater == user and same_fields?(new, :user)) or updater.administrator?
  end

  def deletable_by?(deleter)
    deleter.administrator?
  end

  def viewable_by?(viewer, field)
    true
  end

end
